package com.xianyun.book.domain.order;

import com.alibaba.cola.domain.Entity;
import com.xianyun.book.domain.common.CountEnum;
import com.xianyun.book.domain.common.util.DateCompareUtil;
import com.xianyun.book.domain.pay.PayStatus;
import com.xianyun.book.domain.user.ReceiveAddress;
import lombok.Data;
import java.util.Date;

/**
 * 订单
 * @author ytt
 */
@Entity
@Data
public class Order {
    /**订单ID*/
    private String orderId;
    /**书籍关联*/
    private String isbn;
    /**书籍数量*/
    private Integer bookNumber;
    /**收件人*/
    private String recipient;
    /**收件地址*/
    private String shippingAddress;
    /**邮编*/
    private String postCode;
    /**手机号*/
    private String phoneNumber;
    /**交易ID*/
    private Integer paymentId;
    /**订单类型*/
    private OrderType orderType;
    /**支付状态*/
    private PayStatus payStatus;
    /**订单状态*/
    private OrderStatus orderStatus;
    /**关联ID*/
    private String relateOrderId;
    /**收货物地址 若非买方时不填值*/
    private ReceiveAddress receiveAddress;
    /**用户ID*/
    private String userId;
    /**创建时间*/
    private Date createTime;
    /**付款时间*/
    private Date payTime;
    /**发货时间*/
    private Date sendTime;
    /**成交时间*/
    private Date finishTime;

    public boolean filterByDayCount(CountEnum countEnum){
        int countDay = countEnum.getCountSelectDay();
        if (countDay != 0){
            Date currentDate = new Date();
            Date startDate = DateCompareUtil.getPastDate(countDay);
            return DateCompareUtil.isEffectiveDate(createTime,startDate,currentDate);
        }
        return true;
    }
}
